﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;

namespace IPMS
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //Dashboard
            routes.MapRoute(
                "Dashboard",
                "",
                new { controller = "Dashboard", action = "Index" }
            );
            //Login
            routes.MapRoute(
                "Login",
                "login",
                new { controller = "User", action = "Login", returnUrl = UrlParameter.Optional }
                );
            //Logout
            routes.MapRoute(
                "Logout",
                "logout",
                new { controller = "User", action = "Logout" }
            );
            #region Routes for PackageController
            routes.MapRoute(
                "PackageUpdate",
                "package/up/{id}",
                new { controller = "Package", action = "Update", id = UrlParameter.Optional }
                );
            
            routes.MapRoute(
                "PackageDetails",
                "package/details/{id}",
                new { controller = "Package", action = "Details", id = UrlParameter.Optional }
            );
            routes.MapRoute(
                "PackageCreate",
                "package/create/{projectID}",
                new { controller = "Package", action = "Create", projectID = UrlParameter.Optional }
            );
            routes.MapRoute(
                "PackageList",
                "package/list/{projectID}",
                new { controller = "Package", action = "List", projectID = UrlParameter.Optional }
            );
            routes.MapRoute(
                 "InviteList",
                 "package/inviting/list/{packageID}",
                 new { controller = "Package", action = "ListInviting", packageID = UrlParameter.Optional }
            );
            routes.MapRoute(
                "InviteCreate",
                "package/inviting/create/{packageID}",
                new { controller = "Package", action = "CreateInviting", packageID = UrlParameter.Optional }
                );
            routes.MapRoute(
                "OpenList",
                "package/open/list/{packageID}",
                new { controller = "Package", action = "OpenList", packageID = UrlParameter.Optional }
            );
            #endregion
            #region Routes for BidderController
            routes.MapRoute(
                "CreateBidder",
                "bidder/create",
                new { controller = "Bidder", action = "Create" }
                );
            #endregion

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Dashboard", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );



        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            RegisterRoutes(RouteTable.Routes);
        }
    }
}